package cn.edu.cqut.test0507;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class Test3 {
	public static void main(String[] args) throws Exception {
		File src = new File("大文件.mp4");
		File dest = new File("E:\\"+src.getName());
		//耗时：136202
//		InputStream inputStream = new FileInputStream(src);
//		OutputStream outputStream = new FileOutputStream(dest);
		//耗时：136706
		InputStream inputStream = new BufferedInputStream(new FileInputStream(src));
		OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(dest));
		int len = -1;
		byte[] data = new byte[1024];
		long startTime = System.currentTimeMillis();
		while((len = inputStream.read(data, 0, data.length))!=-1)
		{
			outputStream.write(data, 0, len);
		}
		outputStream.flush();
		outputStream.close();
		inputStream.close();
		long endTime = System.currentTimeMillis();
		System.out.println("耗时："+(endTime-startTime));
	}
}
